
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta charset="utf-8" />
    <title>iprPy.tools package &#8212; iprPy 0.10.2 documentation</title>
    <link rel="stylesheet" href="../_static/basic.css" type="text/css" />
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    <script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
    <script type="text/javascript" src="../_static/jquery.js"></script>
    <script type="text/javascript" src="../_static/underscore.js"></script>
    <script type="text/javascript" src="../_static/doctools.js"></script>
    <script type="text/javascript" src="../_static/language_data.js"></script>
    <script crossorigin="anonymous" integrity="sha256-Ae2Vz/4ePdIu6ZyI/5ZGsYnb+m0JlOmKPjt6XZ9JJkA=" type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script>
    <script async="async" type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest.js?config=TeX-AMS-MML_HTMLorMML"></script>
    <script type="text/x-mathjax-config">MathJax.Hub.Config({"tex2jax": {"inlineMath": [["$", "$"], ["\\(", "\\)"]], "processEscapes": true, "ignoreClass": "document", "processClass": "math|output_area"}})</script>
    <link rel="index" title="Index" href="../genindex.html" />
    <link rel="search" title="Search" href="../search.html" />
    <link rel="prev" title="iprPy.record package" href="record.html" /> 
  </head><body>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="record.html" title="iprPy.record package"
             accesskey="P">previous</a> |</li>
        <li class="nav-item nav-item-0"><a href="../index.html">iprPy 0.10.2 documentation</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="index.html" accesskey="U">iprPy package</a> &#187;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  <div class="section" id="iprpy-tools-package">
<h1>iprPy.tools package<a class="headerlink" href="#iprpy-tools-package" title="Permalink to this headline">¶</a></h1>
<div class="section" id="module-iprPy.tools">
<span id="module-contents"></span><h2>Module contents<a class="headerlink" href="#module-iprPy.tools" title="Permalink to this headline">¶</a></h2>
<dl class="function">
<dt id="iprPy.tools.aslist">
<code class="sig-name descname">aslist</code><span class="sig-paren">(</span><em class="sig-param">term</em><span class="sig-paren">)</span><a class="headerlink" href="#iprPy.tools.aslist" title="Permalink to this definition">¶</a></dt>
<dd><p>Create list representation of term. Treats a str, unicode term as a single
item.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>term</strong> (<em>any</em>) – Term to convert into a list, if needed.</p>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>All items in term as a list</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>list of any</p>
</dd>
</dl>
</dd></dl>

<dl class="function">
<dt id="iprPy.tools.dynamic_import">
<code class="sig-name descname">dynamic_import</code><span class="sig-paren">(</span><em class="sig-param">module_name</em>, <em class="sig-param">ignorelist=None</em><span class="sig-paren">)</span><a class="headerlink" href="#iprPy.tools.dynamic_import" title="Permalink to this definition">¶</a></dt>
<dd><p>Dynamically imports classes stored in submodules and makes them directly
accessible by style name within the returned loaded dictionary.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>module_name</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.8)"><em>str</em></a>) – The name of the module to start from</p></li>
<li><p><strong>ignorelist</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#list" title="(in Python v3.8)"><em>list</em></a><em>, </em><em>optional</em>) – A list of submodules that should be excluded from the import.</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p><ul class="simple">
<li><p><strong>loaded</strong> (<em>dict</em>) – Contains the derived classes that were successfully loaded and
accessible by style name (root submodule).</p></li>
<li><p><strong>failed</strong> (<em>dict</em>) – Contains the raised error messages for each class that failed
to load.</p></li>
</ul>
</p>
</dd>
</dl>
</dd></dl>

<dl class="function">
<dt id="iprPy.tools.filltemplate">
<code class="sig-name descname">filltemplate</code><span class="sig-paren">(</span><em class="sig-param">template</em>, <em class="sig-param">variable</em>, <em class="sig-param">s_delimiter</em>, <em class="sig-param">e_delimiter</em><span class="sig-paren">)</span><a class="headerlink" href="#iprPy.tools.filltemplate" title="Permalink to this definition">¶</a></dt>
<dd><p>Takes a template and fills in values for delimited template variables.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>template</strong> (<em>string</em><em> or </em><em>file-like object</em>) – The template file or file content to fill in.</p></li>
<li><p><strong>variable</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#dict" title="(in Python v3.8)"><em>dict</em></a>) – Dictionary with keys defining the delimited template variable terms,
and values the values to replace the variable terms with.</p></li>
<li><p><strong>s_delimiter</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.8)"><em>str</em></a>) – The leading delimiter for identifying the template variable terms.</p></li>
<li><p><strong>e_delimiter</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.8)"><em>str</em></a>) – The trailing delimiter for identifying the template variable terms.</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>The template with all delimited variable terms replaced with their
corresponding defined values from variable.</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.8)">str</a></p>
</dd>
<dt class="field-even">Raises</dt>
<dd class="field-even"><ul class="simple">
<li><p><a class="reference external" href="https://docs.python.org/3/library/exceptions.html#KeyError" title="(in Python v3.8)"><strong>KeyError</strong></a> – If delimited term found in template that has no value in variable.</p></li>
<li><p><a class="reference external" href="https://docs.python.org/3/library/exceptions.html#ValueError" title="(in Python v3.8)"><strong>ValueError</strong></a> – If parsing of s_delimiter, e_delimiter pairs fails.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="function">
<dt id="iprPy.tools.iaslist">
<code class="sig-name descname">iaslist</code><span class="sig-paren">(</span><em class="sig-param">term</em><span class="sig-paren">)</span><a class="headerlink" href="#iprPy.tools.iaslist" title="Permalink to this definition">¶</a></dt>
<dd><p>Iterate over items in term as if term was a list. Treats a str, unicode
term as a single item.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>term</strong> (<em>any</em>) – Term to iterate over.</p>
</dd>
<dt class="field-even">Yields</dt>
<dd class="field-even"><p><em>any</em> – Items in the list representation of term.</p>
</dd>
</dl>
</dd></dl>

<dl class="function">
<dt id="iprPy.tools.read_calc_file">
<code class="sig-name descname">read_calc_file</code><span class="sig-paren">(</span><em class="sig-param">filename</em>, <em class="sig-param">filedict</em><span class="sig-paren">)</span><a class="headerlink" href="#iprPy.tools.read_calc_file" title="Permalink to this definition">¶</a></dt>
<dd><p>Utility function for reading the contents of required calculation files, whether
the calculation was called using the script or through an iprPy Calculation
object.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>filename</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.8)"><em>str</em></a>) – The name of the file to read/get content for.</p></li>
<li><p><strong>filedict</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#dict" title="(in Python v3.8)"><em>dict</em></a>) – Should be empty if calculation is called by script, and should have all
file names and contents if calculation is called through iprPy.</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>The file’s contents, either by reading the file or from filedict</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.8)">str</a></p>
</dd>
</dl>
</dd></dl>

<dl class="function">
<dt id="iprPy.tools.screen_input">
<code class="sig-name descname">screen_input</code><span class="sig-paren">(</span><em class="sig-param">prompt=''</em><span class="sig-paren">)</span><a class="headerlink" href="#iprPy.tools.screen_input" title="Permalink to this definition">¶</a></dt>
<dd><p>Replacement input function that is compatible with the mingw terminal.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>prompt</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.8)"><em>str</em></a><em>, </em><em>optional</em>) – The screen prompt to use for asking for the input.</p>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>The user input.</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.8)">str</a></p>
</dd>
</dl>
</dd></dl>

</div>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
  <h3><a href="../index.html">Table of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">iprPy.tools package</a><ul>
<li><a class="reference internal" href="#module-iprPy.tools">Module contents</a></li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="record.html"
                        title="previous chapter">iprPy.record package</a></p>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="record.html" title="iprPy.record package"
             >previous</a> |</li>
        <li class="nav-item nav-item-0"><a href="../index.html">iprPy 0.10.2 documentation</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="index.html" >iprPy package</a> &#187;</li> 
      </ul>
    </div>
    <div class="footer" role="contentinfo">
      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 2.1.2.
    </div>
  </body>
</html>